{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "vscode": {
     "languageId": "plaintext"
    }
   },
   "source": [
    "# Welcome to AdalFlow 🤗\n",
    "AdalFlow is your go-to library for building and auto-optimizing LLM task pipelines. We're dedicated to providing an exceptional LLM application development experience.\n",
    "\n",
    "For questions or support, [join our Discord community](https://discord.gg/ezzszrRZvT).\n",
    "\n",
    "⭐ [Star us on GitHub!](https://github.com/SylphAI-Inc/AdalFlow) ⭐\n",
    "\n",
    "### Quick Links\n",
    "* [GitHub Repository](https://github.com/SylphAI-Inc/AdalFlow)\n",
    "* [Full Tutorials](https://adalflow.sylph.ai/index.html#)\n",
    "* [Developer Notes](https://adalflow.sylph.ai/tutorials/index.html)\n",
    "* [Use Cases](https://adalflow.sylph.ai/use_cases/index.html)\n",
    "\n",
    "### Authors\n",
    "This notebook was created by [Nicholas Fleischhauer](https://www.linkedin.com/in/unobtainiumrock)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import clear_output\n",
    "\n",
    "!pip install -U adalflow\n",
    "\n",
    "clear_output()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Some Initial Setup\n",
    "\n",
    "The following will set up some logging and prompt you to provide API keys for the client we are integrating."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "API keys have been set.\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from getpass import getpass\n",
    "\n",
    "XAI_API_KEY = getpass(\"Please enter your xAI API key:\")\n",
    "\n",
    "os.environ[\"XAI_API_KEY\"] = XAI_API_KEY\n",
    "\n",
    "print(\"API keys have been set.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[xAI] Response: Hi! Hello world!\n"
     ]
    }
   ],
   "source": [
    "from adalflow.components.model_client import XAIClient\n",
    "from adalflow.core import Generator\n",
    "\n",
    "generator = Generator(\n",
    "    model_client=XAIClient(),\n",
    "    model_kwargs={\n",
    "        \"model\": \"grok-2-latest\",\n",
    "        \"temperature\": 0,\n",
    "        \"stream\": False,\n",
    "    },\n",
    ")\n",
    "\n",
    "prompt_kwargs = {\"input_str\": \"Testing. Just say hi and hello world and nothing else.\"}\n",
    "\n",
    "# Call the generator\n",
    "response = generator(prompt_kwargs)\n",
    "\n",
    "if response.error:\n",
    "    print(f\"[xAI] Generator Error: {response.error}\")\n",
    "else:\n",
    "    print(f\"[xAI] Response: {response.data}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
